package MVC.view;

import javax.swing.tree.DefaultMutableTreeNode;


public class MyTreeNode extends DefaultMutableTreeNode {

	private Integer version = null;
	private boolean checked = false;
	private boolean hasError = false;
	
	
	public MyTreeNode(String Name){
		super(Name);
	}
	
	public MyTreeNode(String Name,Integer version){
		super(Name);
		this.setVersion(version);
	}
	
	public MyTreeNode(String Name,Integer version,String date){
		super(date+" : "+Name);
		this.setVersion(version);
	}

	
	
	public void setVersion(Integer version) {
		this.version = version;
	}

	public Integer getVersion() {
		return version;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public boolean isChecked() {
		return checked;
	}

	public String getName(){
		return this.toString();
	}
	
	/**
	* getLevel
	*
	* @return int
	*/
	public int getLevel(){
		int count = -1;
	    MyTreeNode current = this;
	    do{
	    	current = (MyTreeNode) current.getParent();
	        count++;
	    }
	    while (current != null);
	    return count;
	}

	public void setHasError(boolean hasError) {
		this.hasError = hasError;
	}

	public boolean isHasError() {
		return hasError;
	}  
	
}
